Ext.define('jwawa.erp.common.AdvanceSearchWin', {
    extend: 'Ext.window.Window',
    alias: 'widget.advanceSearchPanelWin',
    handlerClass: 'jwawa.erp.common.AdvanceSearchWinHandler',
    searchPanel: null,
    height: 350,
    width: 564,
    closeAction: 'hide',
    layout: {
        type: 'border'
    },
    title: '自定义查询',
    border: 0,
    items: [
        {
            itemId: 'searchGrpTreePanel',
            xtype: 'treepanel',
            region: 'west',
            split: true,
            frame: false,
            lines: false,
            width: 175,
            animCollapse: false,
            collapseFirst: false,
            header: false,
            title: '快捷查询',
            rootVisible: false,
            autoScroll: true,
            viewConfig: {

            },
            selType: 'rowmodel',
            multiSelect: true,
                plugins: [{
                ptype: 'cellediting',
                clicksToEdit: 2,
                pluginId: 'cellplugin'
            }],
            hideHeaders:true,
            columns: [{
                xtype: 'treecolumn',
                dataIndex: 'text',
                flex: 1,
                editor: {
                    xtype: 'textfield',
                    selectOnFocus: true,
                    allowBlank: false
                }
            }],
            dockedItems: [
                {
                    itemId: 'searchGrpToolbar',
                    xtype: 'toolbar',
                    hidden: false,
                    dock: 'top',
                    items: [
                        {
                            itemId: 'addGrpButton',
                            xtype: 'button',
                            icon: '/img/flag_blue_add.png',
                            text: '新增'
                        },
                        {
                            itemId: 'delGrpButton',
                            xtype: 'button',
                            icon: '/img/flag_blue_delete.png',
                            text: '删除'
                        },
                        {
                            itemId: 'setDefaultGrpButton',
                            xtype: 'button',
                            icon: '/img/flag_red.png',
                            text: '默认'
                        }
                    ]
                }
            ]
        },
        {
            itemId: 'searchItemPanel',
            xtype: 'form',
            region: 'center',
            bodyPadding: 10,
            header: false,
            title: '查询条件',
            autoScroll: true,
            layout: {
                align: 'stretch',
                type: 'vbox'
            },
            dockedItems: [
                {
                    xtype: 'toolbar',
                    dock: 'top',
                    items: [
                        {
                            itemId: 'saveSearchItemButton',
                            xtype: 'button',
                            icon: '/img/disk.png',
                            text: '保存',
                            disabled: true
                        },
                        {
                            itemId: 'addSearchItemButton',
                            xtype: 'button',
                            icon: '/img/application_form_add.png',
                            text: '添加'
                        },
                        {
                            itemId: 'emptySearchItemButton',
                            xtype: 'button',
                            icon: '/img/trash_empty.gif',
                            text: '清空'
                        },
                        {
                            xtype: 'tbseparator'
                        },
                        {
                            itemId: 'searchAdvanceSearchButton',
                            xtype: 'button',
                            icon: '/img/application_form_magnify.png',
                            text: '查询'
                        },
                        {
                            itemId: 'closeAdvanceSearchWinButton',
                            xtype: 'button',
                            icon: '/img/door_out.png',
                            text: '关闭'
                        }
                    ]
                }
            ]
        }
    ],

    initComponent: function() {
        var me = this,
            handler = null;

        if(Ext.isString(me.handlerClass)){
            handler = Ext.create(me.handlerClass, {
                view: me
            });
            me.handler = handler;
        }

        me.callParent(arguments);
        me.addListener('afterrender', function(){
            handler.bindHandler();
        });
    }
});